import React from "react";
import { customComponentMap } from "./config";

interface IComponentProps {
    is: string;
    [key: string]: any;
}
const CMSComponent: React.FC<IComponentProps> = ({ is, children, ...restProps }) => {
    try {
        const Comp = require("antd")[is] || Reflect.get(customComponentMap, is);
        if (!Comp) return null;
        console.log(Comp, restProps)
        return <Comp {...restProps}>{children}</Comp>;
    }catch{
        return null;
    }
};

export default CMSComponent;